package com.sopt.view;

import com.sopt.friends.ChatActivity;
import com.sopt.friends.FirstActivity;
import com.sopt.friends.GroupActivity;
import com.sopt.friends.R;
import com.sopt.friends.SettingActivity;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TableLayout;

public class BottomMenuLayout extends TableLayout {
	Context c;
	Button btnHome;
	Button btnGroup;
	Button btnChat;
	Button btnSetting;

	public BottomMenuLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		c = context;
		
		LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		inflater.inflate(R.layout.bottommenu, this, true);
		
		btnHome = (Button) findViewById(R.id.btnHome);
		btnGroup = (Button) findViewById(R.id.btnGroup);
		btnChat = (Button) findViewById(R.id.btnChat);
		btnSetting = (Button) findViewById(R.id.btnSetting);
		
		setBtnsListeners();
	}

	private void setBtnsListeners() {
		btnHome.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(c,FirstActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				v.getContext().startActivity(intent);
			}
		});
		btnGroup.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(c,GroupActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				v.getContext().startActivity(intent);
			}
		});
		btnChat.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(c,ChatActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				v.getContext().startActivity(intent);
			}
		});
		btnSetting.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(c,SettingActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				v.getContext().startActivity(intent);
			}
		});
		
	}
}
